
int moveBullet(Bullet *theBullet) {
	
	if (theBullet->animationFunction != 0) {
		void (*animatef)(Bullet*) = theBullet->animationFunction;
		(*animatef)(theBullet);
	}
	
	theBullet->pos.x += theBullet->velocity.x;
	theBullet->pos.y += theBullet->velocity.y;
	theBullet->pos.z += theBullet->velocity.z;
	
	float limit = 600.f;
	if (fabsf(theBullet->pos.x) > limit || fabsf(theBullet->pos.y) > limit || fabsf(theBullet->pos.z) > limit) {
		return 1;
	}
	return 0;
}

int checkBulletCollision(PlayerObject *player1, PlayerObject *player2, Bullet *theBullet) {
	if (theBullet->player == player1 && player2->effect == 0) {
		if (checkCollision(modelArray[theBullet->model]->radius, theBullet->pos, modelArray[theBullet->model]->meshCenter,
						   player2->mesh->radius, player2->pos, player2->mesh->meshCenter)) {
			player2->life -= theBullet->damage;
			if (player2->life <= 0) {
				playerKilled(player1,player2, theBullet->killAnimation);
			}
			return 1;
		}
	}
	if (theBullet->player == player2 && player1->effect == 0) {
		if (checkCollision(modelArray[theBullet->model]->radius, theBullet->pos, modelArray[theBullet->model]->meshCenter,
						   player1->mesh->radius, player1->pos, player1->mesh->meshCenter)) {
			player1->life -= theBullet->damage;
			if (player1->life <= 0) {
				playerKilled(player2,player1, theBullet->killAnimation);
			}
			return 1;
		}
	}
	return 0;
}

int checkBulletCollisionObject(Bullet *theBullet, CollisionObject *obj) {
	if (obj->collideType == OBJECT_BUMP) {
		if (checkCollision(modelArray[theBullet->model]->radius, theBullet->pos, modelArray[theBullet->model]->meshCenter,
						   modelArray[obj->model]->radius, obj->pos, modelArray[obj->model]->meshCenter)) {
			return 1;
		}
	}
	if (obj->collideType == OBJECT_IMMOVABLE) {
		if (checkCollision(modelArray[theBullet->model]->radius, theBullet->pos, modelArray[theBullet->model]->meshCenter,
						   modelArray[obj->model]->radius, obj->pos, modelArray[obj->model]->meshCenter)) {
			return 1;
		}
	}
	return 0;
}